<%@ include file="../common/top.jsp" %>

<div id="BackLink">
  <a href="mainForm">Return to Main Menu</a>
</div>

<div id="Catalog">
  <form action="signOn" method="post">
    <p>Please enter your username and password.</p>
    <c:if test="${requestScope.signOnMsg!=null}">
      <p><font color="red">${requestScope.signOnMsg}</font></p>
    </c:if>
    <!-- 在这里嵌入JavaScript代码 -->
    <script type="text/javascript">
      document.addEventListener("DOMContentLoaded", function () {
        var imagecode = document.getElementById("imagecode");

        // 添加点击事件监听器
        imagecode.addEventListener("click", function () {
          // 创建新的URL以避免缓存
          var currentSrc = imagecode.src;
          var separator = currentSrc.indexOf("?") !== -1 ? "&" : "?";
          var newSrc = currentSrc + separator + "timestamp=" + new Date().getTime();

          // 更新验证码图片的src属性
          imagecode.src = newSrc;
        });
      });
    </script>
    <p>
      Username:<input type="text" name="username"> <br />
      Password:<input type="password" name="password"><br />
      Verification Code:<input type="text" id="code2" name="checkCode2">
      <!--验证码-->
      <img alt="验证码" id="imagecode" src="<%= request.getContextPath()%>/imageServlet"/>
    </p>
    <input type="submit" value="Login">
  </form>


  Need a user name and password?

  <a href="newAccountForm">Register Now!</a>
</div>

<%@ include file="../common/bottom.jsp" %>

